package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceTime;
import com.ruoyi.service.service.IServiceTimeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 时间信息表Controller
 * 
 * @author ZDL
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/service/time")
public class ServiceTimeController extends BaseController
{
    @Autowired
    private IServiceTimeService serviceTimeService;

    /**
     * 查询时间信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:time:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceTime serviceTime)
    {
        startPage();
        List<ServiceTime> list = serviceTimeService.selectServiceTimeList(serviceTime);
        return getDataTable(list);
    }

    /**
     * 导出时间信息表列表
     */
    @PreAuthorize("@ss.hasPermi('service:time:export')")
    @Log(title = "时间信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceTime serviceTime)
    {
        List<ServiceTime> list = serviceTimeService.selectServiceTimeList(serviceTime);
        ExcelUtil<ServiceTime> util = new ExcelUtil<ServiceTime>(ServiceTime.class);
        util.exportExcel(response, list, "时间信息表数据");
    }

    /**
     * 获取时间信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:time:query')")
    @GetMapping(value = "/{timeId}")
    public AjaxResult getInfo(@PathVariable("timeId") Long timeId)
    {
        return success(serviceTimeService.selectServiceTimeByTimeId(timeId));
    }

    /**
     * 新增时间信息表
     */
    @PreAuthorize("@ss.hasPermi('service:time:add')")
    @Log(title = "时间信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceTime serviceTime)
    {
        return toAjax(serviceTimeService.insertServiceTime(serviceTime));
    }

    /**
     * 修改时间信息表
     */
    @PreAuthorize("@ss.hasPermi('service:time:edit')")
    @Log(title = "时间信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceTime serviceTime)
    {
        return toAjax(serviceTimeService.updateServiceTime(serviceTime));
    }

    /**
     * 删除时间信息表
     */
    @PreAuthorize("@ss.hasPermi('service:time:remove')")
    @Log(title = "时间信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{timeIds}")
    public AjaxResult remove(@PathVariable Long[] timeIds)
    {
        return toAjax(serviceTimeService.deleteServiceTimeByTimeIds(timeIds));
    }
}
